package cn.jhh.base.exception;

/**
 * @author hmxchen
 * @version 1.0
 * @description TODO
 * @date 2023/1/30 11:15
 */
public class CustomException extends RuntimeException {

    private String errMessage;

    public CustomException() {
        super();
    }

    public CustomException(String message) {
        super(message);
        this.errMessage = message;
    }

    public String getErrMessage(){
        return errMessage;
    }

    public static void cast(String errMessage){
        throw new CustomException(errMessage);
    }
    public static void cast(CommonError commonError){
        throw new CustomException(commonError.getErrMessage());
    }
    public static CustomException init(String errMessage){
        return new CustomException(errMessage);
    }

    public static CustomException init(CommonError commonError){
        return new CustomException(commonError.getErrMessage());
    }
}
